package com.lmiot.xyclick.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.lmiot.xyclick.AD.SplashActivity;
import com.lkx.liandianqinew.R;
import com.lmiot.xyclick.Util.DataUtil;
import com.youyi.yyviewsdklibrary.Dialog.util.ToastUtil;
import github.chenupt.springindicator.SpringIndicator;
import java.util.ArrayList;
import java.util.List;

public class FirstGuideActivity extends BaseActivity {
    private long exitTime = 0;
    ViewPager mIdViewpager;
    SpringIndicator mIndicator;
    private List<View> mViewList;

    /* access modifiers changed from: protected */
    @Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.SupportActivity, android.support.v4.app.FragmentActivity, com.lmiot.xyclick.Activity.BaseActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        requestWindowFeature(1);
        getWindow().setFlags(1024, 1024);
        setContentView(R.layout.activity_first_guide);
        initView();
        setViewpager();
    }

    private void setViewpager() {
        ArrayList arrayList = new ArrayList();
        this.mViewList = arrayList;
        arrayList.add(View.inflate(this, R.layout.activity_help01, null));
        this.mViewList.add(View.inflate(this, R.layout.activity_help02, null));
        View inflate = View.inflate(this, R.layout.activity_help03, null);
        ((TextView) inflate.findViewById(R.id.id_start)).setOnClickListener(new View.OnClickListener() {
            /* class com.lmiot.xyclick.Activity.FirstGuideActivity.AnonymousClass1 */

            public void onClick(View view) {
                DataUtil.setHasShowGuide(FirstGuideActivity.this, true);
                FirstGuideActivity.this.startActivity(new Intent(FirstGuideActivity.this, SplashActivity.class));
                FirstGuideActivity.this.finish();
            }
        });
        this.mViewList.add(inflate);
        this.mIdViewpager.setAdapter(new MyApdapter());
        this.mIndicator.setViewPager(this.mIdViewpager);
    }

    private void initView() {
        this.mIdViewpager = (ViewPager) findViewById(R.id.id_viewpager);
        this.mIndicator = (SpringIndicator) findViewById(R.id.indicator);
    }

    /* access modifiers changed from: private */
    public class MyApdapter extends PagerAdapter {
        @Override // android.support.v4.view.PagerAdapter
        public boolean isViewFromObject(View view, Object obj) {
            return view == obj;
        }

        private MyApdapter() {
        }

        @Override // android.support.v4.view.PagerAdapter
        public int getCount() {
            return FirstGuideActivity.this.mViewList.size();
        }

        @Override // android.support.v4.view.PagerAdapter
        public Object instantiateItem(ViewGroup viewGroup, int i) {
            View view = (View) FirstGuideActivity.this.mViewList.get(i);
            viewGroup.addView(view);
            return view;
        }

        @Override // android.support.v4.view.PagerAdapter
        public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
            viewGroup.removeView((View) FirstGuideActivity.this.mViewList.get(i));
        }

        @Override // android.support.v4.view.PagerAdapter
        public CharSequence getPageTitle(int i) {
            return (i + 1) + "";
        }
    }

    @Override // android.support.v7.app.AppCompatActivity
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i != 4) {
            return super.onKeyDown(i, keyEvent);
        }
        exit();
        return false;
    }

    public void exit() {
        try {
            if (System.currentTimeMillis() - this.exitTime > 2000) {
                ToastUtil.info("再按一次退出程序");
                this.exitTime = System.currentTimeMillis();
                return;
            }
            finish();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
